// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import "bootstrap/dist/css/bootstrap.min.css"
import './assets/css/custom.css'
import "bootstrap/dist/js/bootstrap.min"
import Vue from 'vue'
import App from './App'
import router from './router'
import util from './common/util'
import ElementUi from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import store from '@/store/index'

Vue.use(ElementUi);
Vue.use(util);

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  //把store对象提供给 store 可以把实例注入到所有的子组件,子组建可以通过store来获得实例
  store,
  components: { App },
  template: '<App/>'
})

// 路由跳转
Vue.prototype.$goRoute = function (index) {
  this.$router.push(index)
}
// 注册一个全局自定义指令 v-focus
Vue.directive('focus', {
  // 当绑定元素插入到 DOM 中。
  inserted: function (el) {
    // 聚焦元素
    el.focus()
  }
});

//注册全局自定义指令 页面标题
Vue.directive('page-title', {
  inserted: function (el, binding) {
    document.title = binding.value
  }
});
// 路由发生变化修改页面title
router.beforeEach((to, from, next) => {
  document.title = to.meta.title + ' - 后台管理系统';
  next();
});
